<template>
  <div>
    <el-dialog title="冻结信息" :visible.sync="freezeDialogvis" @close="close" width="420px" append-to-body :close-on-click-modal="false">
        <el-form :model="freezeForm" ref="freezeForm">

            <el-form-item label="当前库存:" :label-width="formLabelWidth">
                <el-input size="small" v-model="freezeForm.current_stock" disabled></el-input>
            </el-form-item>
            <el-form-item label="冻结数量:" :label-width="formLabelWidth">
                <el-input size="small" v-model="freezeForm.freeze_num"></el-input>
            </el-form-item>
            <el-form-item label="冻结原因:" :label-width="formLabelWidth">
               <el-input size="small" type="textarea" v-model="freezeForm.freeze_reason" placeholder=""></el-input>
            </el-form-item>
            <el-form-item label="冻结责任人:" :label-width="formLabelWidth">
               <el-input size="small" v-model="freezeForm.freeze_person" placeholder=""></el-input>
            </el-form-item>
            <el-form-item label="冻结时间:" :label-width="formLabelWidth">
                <el-date-picker style="width:100%" size="small" type="date" placeholder="选择日期" v-model="freezeForm.freeze_date">
                </el-date-picker>
            </el-form-item>

        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="close">取 消</el-button>
          <el-button type="danger" :loading="submitLoading" @click="submitFreeze('freezeForm')">确 定</el-button>
        </div>
          </el-dialog>
        </div>
</template>

<script>
import { AddStoreArea, UpdateArea } from '@/api/store.js';

export default {
  name: 'addstore',
  props: ['openFreezeDialog'],
  data() {
    return {
      freezeDialogvis: false,
      submitLoading: false,
      freezeForm: {
        current_stock: '',
        freeze_num: '',
        freeze_reason: '',
        freeze_person: '',
        freeze_date: new Date(),
      },
      formLabelWidth: '100px',
    }
  },
  mounted() {
    // console.log(this.checkArea)
    // this.freezeForm.areaNumber = this.checkArea.areaNumber;
    // this.addAreaForm.areaName = this.checkArea.areaName;
    // this.addAreaForm.areaRemarks = this.checkArea.areaRemarks;
  },
  computed: {
    main_store() {
      return this.$store.state.store.main_store;
    },
    store_id() {
      return this.$store.state.store.store_id;
    },
  },
  methods: {
    close() {
      this.freezeDialogvis = false;
      this.resetForm();
      this.$emit("update:openFreezeDialog", false);
    },
    resetForm() {
      this.freezeForm.freeze_reason = '';
      this.freezeForm.freeze_person = '';
    },
    submitFreeze(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.submitLoading = true;
          // let reqData = {
          //     areaNumber: this.addAreaForm.areaNumber,
          //     areaName: this.addAreaForm.areaName,
          //     warehouseId: this.store_id,
          //     areaRemarks: this.addAreaForm.areaRemarks,
          // }
          // AddStoreArea(reqData).then(response => {
          //     let data = response.data
          //     this.$message({
          //         message: data.msg,
          //         type: 'success'
          //     })
          //     this.submitLoading = false;
          //     this.$refs.addstorearea.resetFields();
          //     this.freezeDialogvis = false;
          //     this.resetForm();
          //     this.$emit("update:openFreezeDialog", false);
          // }).catch(error => {
          //     this.submitLoading = false;
          // })
  
        } else {
          console.log('error submit!!');
          return false;
        }
      });
      
    }
  },
  watch: {
    openFreezeDialog(newVal,oldVal) {  
      this.freezeDialogvis = newVal;
    }
  }
}
</script>

<style lang="scss" scoped>
  
</style>